﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using AcctrueWMS.Foundation.Web;

namespace AcctrueWMS.Foundation.Data
{
    [Serializable]
    public class DataModelColumn
    {
        /// <summary>
        /// 所属DataModel
        /// </summary>
        public DataModel Model
        {
            get;
            set;
        }
        /// <summary>
        /// 列名
        /// </summary>
        public string Name
        {
            get;
            set;
        }
        /// <summary>
        /// 显示名
        /// </summary>
        public string DisplayName
        {
            get;
            set;
        }
        /// <summary>
        /// 最大长度
        /// </summary>
        public int MaxLength
        {
            get;
            set;
        }
        /// <summary>
        /// 长度
        /// </summary>
        public string Length
        {
            get;
            set;
        }
        /// <summary>
        /// 宽度
        /// </summary>
        public string Width
        {
            get;
            set;
        }
        /// <summary>
        /// 高度
        /// </summary>
        public string Height
        {
            get;
            set;
        }
        /// <summary>
        /// 格式
        /// </summary>
        public string Format
        {
            get;
            set;
        }
        /// <summary>
        /// 显示类型 参考DataModelColumnDisplayTypeEnum
        /// </summary>
        public string DisplayType { get; set; }
        /// <summary>
        /// 列类型
        /// </summary>
        public Type ColumnType
        {
            get;
            set;
        }
        /// <summary>
        /// 是否可空
        /// </summary>
        public bool Nullable
        {
            get;
            set;
        }
        /// <summary>
        /// 是否显示
        /// </summary>
        public bool Visible { get; set; }
        /// <summary>
        /// 是否可用
        /// </summary>
        public bool Enable { get; set; }
        /// <summary>
        /// 是否必填
        /// </summary>
        public bool Musted { get; set; }
        /// <summary>
        /// 是否可查询
        /// </summary>
        public bool Searchable { get; set; }
        /// <summary>
        /// 是否可排序
        /// </summary>
        public bool Sortable { get; set; }
        /// <summary>
        /// 排序规则ASC/DESC
        /// </summary>
        public string Sort { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public string Data { get; set; }
        /// <summary>
        /// 默认值
        /// </summary>
        public string Default { get; set; }
        /// <summary>
        /// 校验表达式
        /// </summary>
        public string ValidPattern { get; set; }

        /// <summary>
        /// 校验未通过提示语
        /// </summary>
        public string Tip { get; set; }

        /// <summary>
        /// Url,在FocusTextBox类型时使用
        /// </summary>
        public string Url { get; set; }
        /// <summary>
        /// 样式
        /// </summary>
        public string Style { get; set; }
        /// <summary>
        /// 显示Member
        /// </summary>
        public string DisplayMember
        {
            get;
            set;
        }
        /// <summary>
        /// 物理/逻辑类型
        /// </summary>
        public string physicalType
        {
            get;
            set;
        }
        /// <summary>
        /// 值Member
        /// </summary>
        public string ValueMember
        {
            get;
            set;
        }
        /// <summary>
        ///   数据验证表达式
        /// </summary>
        public string DataVolideExpr
        {
            get;
            set;
        }
        /// <summary>
        /// Render列
        /// 
        /// </summary>
        /// <returns></returns>
        public string Render()
        {
            return this.Model.Context.RenderColumn(this);
        }
        /// <summary>
        /// Render查询条件
        /// </summary>
        /// <returns></returns>
        public string RenderAsQuery()
        {
            return this.Model.Context.RenderAsQuery(this);
        }
        /// <summary>
        /// Render带参数的长训条件
        /// </summary>
        /// <param name="expr"></param>
        /// <returns></returns>
        public string RenderAsQuery(string expr)
        {
            return this.Model.Context.RenderAsQuery(this, expr);
        }
        /// <summary>
        /// 流水号生成类型,默认为空
        /// </summary>
        public string SequenceNoGenType
        {
            get;
            set;
        }
        /// <summary>
        /// 查询方式，range或single
        /// </summary>
        public string QueryType
        {
            get;
            set;
        }

        /// <summary>
        /// 排序字段,解决虚拟列
        /// </summary>
        public string sortBy
        {
            get;
            set;
        }

        /// <summary>
        /// 获取流水号
        /// </summary>
        /// <returns></returns>
        public string GenerateSequenceNo()
        {
            return this.Model.Context.GetSequenceNo(this);
        }
    }
}
